package cc.vv.btpartyjob.partymanager.server

import android.util.Log
import cc.vv.baselibrary.http.BaseHttpRequest
import cc.vv.baselibrary.util.UserInfoManageUtil
import cc.vv.btpartyjob.partymanager.api.PartyManagerAPI
import cc.vv.btpartyjob.partymanager.moudel.bean.AddPingJiaObj
import cc.vv.btpartyjob.partymanager.moudel.bean.SubmitProjectObj
import cc.vv.btpartyjob.partymanager.moudel.req.*
import cc.vv.btpartyjob.partymanager.moudel.resp.*
import cc.vv.lkbasecomponent.http.lib.setting.Settings
import cc.vv.lklibrary.http.base.okhttpfactory.plugins.httpplugin.MediaTypeWrap
import java.util.*

/**
 * 党务管理相关请求Server
 * Created by Chen.qi on 2018/10/24.
 */
object PartyManagerServer {

    /**
     * 社区大党委--获取社区组织数据接口
     */
    fun getCommunityOrgData(communityId: String, isShow: Boolean = false) {
        val params = HashMap<String, Any>()
        params.put("communityId", communityId)
        val path = PartyManagerAPI.communityOrgUrl
        BaseHttpRequest.getRequest(path, params, CommunityResponseObj::class.java, isShow)
    }

    fun getSheQuZuZhiHttp(shequId: String, isShow: Boolean = true) {
        val params = HashMap<String, Any>()
        params.put("id", shequId)
        val path = PartyManagerAPI.sheQuZuZhiUrl
        BaseHttpRequest.getRequest(path, params, CommunityResponseObj::class.java, isShow)
    }

    /**
     * 获取网格列表数据
     */
    fun getGridList(communityId: String, isShow: Boolean = false) {
        val params = HashMap<String, Any>()
        params.put("communityId", communityId)
        BaseHttpRequest.getRequest(PartyManagerAPI.gridListUrl, params, GridListResponseObj::class.java, isShow)
    }

    /**
     * 获取事业单位数据
     */
    fun getUnitList(communityId: String, isShow: Boolean = false) {
        val params = HashMap<String, Any>()
        params.put("communityId", communityId)
        BaseHttpRequest.getRequest(PartyManagerAPI.qishiYeDanWeiUrl, params, GridListResponseObj::class.java, isShow)
    }

//    /**
//     * 单元中心户详情
//     */
//    fun getUnitZhongXingDetail(orgId: String) {
//        val params = HashMap<String, Any>()
//        params.put("orgId", orgId)
//        BaseHttpRequest.getRequest(PartyManagerAPI.unitZhongXinDetailUrl, params, DanYuanZhongXinHuResponseObj::class.java, true)
//    }

    /**
     * 获取社区活动
     */
    fun getCommunityActivitiesList(communityId: String?, page: Int?, pageSize: Int, isShow: Boolean = false) {
        val request = CommunityActivitiesRequestObj()
        request.communityId = communityId
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.communityActivitiesUrl, request, CommunityActivitiesResponseObj::class.java, isShow)
    }

    /**
     * 单位报到列表--已经报道
     */
    fun unitRegisterListYes(area: String?, streetId: String?, communityId: String?, type: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = UnitRegisterRequestObj()
        request.area = area
        request.street = streetId
        request.community = communityId
        request.type = type
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.unitRegisterUrl, request, UnitRegisterResponseObj::class.java, isShow)
    }


    /**
     * 单位报到列表--未报道
     */
    fun unitRegisterListNo(area: String?, streetId: String?, communityId: String?, type: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = UnitRegisterRequestObj()
        request.area = area
        request.street = streetId
        request.community = communityId
        request.type = type
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.unitRegisterUrl, request, UnitRegisterNoResponseObj::class.java, isShow)
    }

    /**
     * 单位报到统计
     */
    fun unitReportStatice(streetId: String?, communityId: String?, isShow: Boolean = false) {
        val request = ReportStaticsRequestObj()
        request.street = streetId
        request.community = communityId
        BaseHttpRequest.getRequest(PartyManagerAPI.unitReportStaticsUrl, request, ReportStaticUnitResponseObj::class.java, isShow)
    }

    /**
     * 党员报到统计
     */
    fun partyReportStatice(streetId: String?, communityId: String?, gridId: String?, isShow: Boolean = false) {
        val request = ReportStaticsRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        BaseHttpRequest.getRequest(PartyManagerAPI.partyReportStaticsUrl, request,
                ReportStaticPartyResponseObj::class.java, isShow)
    }


    /**
     * 单位报到详情
     */
    fun unitReportDetail(unitId: String?, isShow: Boolean = false) {
        val request = UnitReportDetailRequestObj()
        request.unitId = unitId
        BaseHttpRequest.getRequest(PartyManagerAPI.unitReportDetailUrl, request, UnitReportDetailResponseObj::class.java, isShow)
    }

    /**
     * 提交单位报到
     */
    fun submitUnitReport(request: SubmitUnitReportRequestObj?, isShow: Boolean = false) {
        BaseHttpRequest.postRequest(PartyManagerAPI.submitUnitReportUrl,
                request, SubmitUnitReportResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 单位报到详情新增资源
     */
    fun unitReportAddResource(request: UnitReportAddResourceRequestObj?, isShow: Boolean = false) {
        BaseHttpRequest.postRequest(PartyManagerAPI.unitReportAddResource,
                request, SubmitUnitReportResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 党员报到列表
     */
    fun partyReportList(page: Int?, pageSize: Int?, requestBody: PartyReportRequestObj, isShow: Boolean = false) {
        val params = HashMap<String, Any>()
        params.put("page", "$page")
        params.put("size", "$pageSize")
        val path = PartyManagerAPI.partyReportListUrl + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, requestBody,
                PartyReportResponseObj::class.java, isShow, Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 党员报到详情
     */
    fun partyReportList(id: String) {
        val params = HashMap<String, Any>()
        params.put("id", id)
        val path = PartyManagerAPI.partyReportDetailUrl + "/$id"
        BaseHttpRequest.getRequest(path, params,
                PartyReportDetailResponseObj::class.java, true)
    }


    /**
     * 党员承诺------已评价列表
     */
    fun partyCommitedList(havingComment: String?, orgId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PartyCommitedRequestObj()
        request.havingComment = havingComment
        request.orgId = orgId
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.partyCommitmentListUrl, request, PartyCommitedResponseObj::class.java, isShow)
    }

    /**
     * 党员承诺------未评价列表
     */
    fun partyCommitedListNo(havingComment: String?, orgId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PartyCommitedRequestObj()
        request.havingComment = havingComment
        request.orgId = orgId
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.partyCommitmentListUrl, request, PartyCommitedNoResponseObj::class.java, isShow)
    }


    /**
     * 单位承诺-------已评价列表
     */
    fun unitCommitedListNo(havingComment: String?, orgId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PartyCommitedRequestObj()
        request.havingComment = havingComment
        request.orgId = orgId
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.unitCommitmentListUrl, request, PartyCommitedNoResponseObj::class.java, isShow)
    }

    /**
     *  单位承诺-------未评价列表
     */
    fun unitCommitedList(havingComment: String?, orgId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PartyCommitedRequestObj()
        request.havingComment = havingComment
        request.orgId = orgId
        request.page = "$page"
        request.pageSize = "$pageSize"
        BaseHttpRequest.getRequest(PartyManagerAPI.unitCommitmentListUrl, request, PartyCommitedResponseObj::class.java, isShow)
    }


    /**
     * 添加承诺信息
     */
    fun addCommitedInfo(content: String?, time: Long?, telPhone: String?, isShow: Boolean = false) {
        val request = AddCommitRequestObj()
        request.content = content
        request.completeTime = time
        request.mobile = telPhone
        request.committedType = 1
        request.targetId = UserInfoManageUtil.getUserId()
        BaseHttpRequest.postRequest(PartyManagerAPI.addCommitInfoUrl,
                request, SubmitUnitReportResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /**
     * 添加单位承诺
     */
    fun addUnitCommitedInfo(unitName: String?, targetId: String?, content: String?, time: Long?, telPhone: String?, isShow: Boolean = false) {
        val request = AddCommitRequestObj()
        request.content = content
        request.completeTime = time
        request.committedUnitName = unitName
        request.mobile = telPhone
        request.committedType = 0
        request.targetId = targetId
        BaseHttpRequest.postRequest(PartyManagerAPI.addCommitInfoUrl,
                request, SubmitUnitReportResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /**
     * 获取街道联席会议信息列表
     */
    fun getStreetMeetingList(streetId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = StreetMeetingRequestObj()
        request.street = streetId
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.streetMeetingList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, StreetMeetingResponseObj::class.java, isShow)
    }

    /**
     * 街道联席会议活动列表
     */
    fun getStreetActivitiesList(streetId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = StreetActivitiesRequestObj()
        request.street = streetId
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.streetActivitiesList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, StreetActivitiesResponseObj::class.java, isShow)
    }

    /**
     * 项目管理，项目查询
     */
    fun projectQuery(name: String?, page: Int?, pageSize: Int?, state: String?, isShow: Boolean = false) {
        val request = ProjectQueryRequestObj()
        request.name = name
        request.page = "$page"
        request.pageSize = "$pageSize"
        request.state = state
        val path = PartyManagerAPI.projectQueryList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, ProjectQueryResponseObj::class.java, isShow)
    }


    /**
     * 项目添加
     */
    fun projectAdd(sub: SubmitProjectObj?, isShow: Boolean = false) {
        val path = PartyManagerAPI.projectAddResource
        BaseHttpRequest.postRequest(path, sub, SubmitUnitReportResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 单位简介
     */
    fun unitIntroduceList(page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = UnitJJRequestObj()
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.unitJJList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, UnitJJResponseObj::class.java, isShow)
    }

    /**
     * 评星晋级
     */
    fun evaluationStarList(page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PolicyDocRequestObj()
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.evaluationStarList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, EvaluationStarResponseObj::class.java, isShow)
    }


    /**
     * 政策文件
     */
    fun policyDocList(page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PolicyDocRequestObj()
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.policyDocument + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, PolicyDocResponseObj::class.java, isShow)
    }

    /**
     * 政策文件
     */
    fun redPartyList(type: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = RedPartyRequestObj()
        request.type = type
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.redPartyListUrl + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, RedPartyResponseObj::class.java, isShow)
    }

    /**
     * 获取项目详情
     */
    fun projectDetail(id: String?, isShow: Boolean = false) {
        val request = ProjectDetailRequestObj()
        val path = PartyManagerAPI.projectDetail + "/$id"
        BaseHttpRequest.getRequest(path, request, ProjectDetailResponseObj::class.java, isShow)
    }

    /**
     * 项目详情取消项目申请
     */
    fun projectDetailCancelApply(id: String?, reasonContent: String?, type: String?) {
        val request = ProjectDetailCancelApplyRequestObj()
        request.id = id
        request.reason = reasonContent
        request.type = type
        val path = PartyManagerAPI.projectDetailYQorCancelApply
        BaseHttpRequest.postRequest(path, request, ProjectDetailCancelApplyResponseObj::class.java, true)
    }


    /**
     * 党员承诺详情
     */
    fun partyPromiseDetailUrl(id: String?) {
        val request = PromiseDetailRequestObj()
        request.id = id
        val path = PartyManagerAPI.promiseDetailUrl
        BaseHttpRequest.getRequest(path, request, PromiseDetailResponseObj::class.java, false)

    }

    /**
     * 党员承诺评价
     */
    fun partyPromisePingJiaList(id: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = PromisePingJiaRequestObj()
        request.committedId = id
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.promisePingJiaListUrl + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, PromisePingJiaResponseObj::class.java, isShow)
    }

    /**
     * 添加评价
     */
    fun addPingJia(id: String?, content: String?) {
        val request = AddPingJiaObj()
        request.committedId = id
        request.content = content
        val path = PartyManagerAPI.addPingJiaUrl + "?committedId=$id"
        BaseHttpRequest.postRequest(path, request, SubmitUnitReportResponseObj::class.java, true,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 获取扶贫行政村信息数据
     */
    fun getFuPingCunInfo(id: String?, isShow: Boolean = false) {
        val request = XzcInfoRequestObj()
        request.villageId = id
        val path = PartyManagerAPI.cunDetailInfo + "/$id"
        BaseHttpRequest.getRequest(path, request, XzcInfoResponseObj::class.java, isShow)
    }

    /**
     * 获取当前用户所在扶贫行政村信息
     */
    fun getCurrentFuPingCunInfo() {
        val request = XzcInfoRequestObj()
        val path = PartyManagerAPI.currentUserFuPingCunInfo
        BaseHttpRequest.getRequest(path, request, GetCurrentFuPingResponseObj::class.java, true)
    }

    /**
     * 获取第一书记信息
     */
    fun getDiYiShuJiInfo(id: String?) {
        Log.e("lk_chen", "result==" + "dskjdkak");
        val request = DiYiShuJiInfoRequestObj()
        request.village = id
        val path = PartyManagerAPI.diYiShuJiInfo
        BaseHttpRequest.getRequest(path, request, DiYiShuJiInfoResponseObj::class.java, true)
    }

    /**
     * 获取四只队伍签到信息
     */
    fun getQianDaoInfo(id: String?, time: String?) {
        Log.e("lk_chen", "result==" + "6666666666");
        val request = QianDaoRequestObj()
        request.teamId = id
        request.time = time
        val path = PartyManagerAPI.getSiZhiDuiWuQianDaoInfo + "/$id"
        BaseHttpRequest.getRequest(path, request, QianDaoResponseObj::class.java, true)
    }


    /**
     * 工作情况列表
     */
    fun workGoingList(teamId: String?, startTime: Long, endTime: Long, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = WorkGoingRequestObj()
        request.teamId = teamId
        request.startTime = "$startTime"
        request.endTime = "$endTime"
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyManagerAPI.workGoingListUrl + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, WorkGoingResponseObj::class.java, isShow)
    }

    /**
     * 获取工作信息
     */
    fun getWorkingInfoDetail(id: String?) {
        val request = GetWorkDetailInfoRequestObj()
        request.id = id
        val path = PartyManagerAPI.getWorkInfoDetailUrl + "/" + "$id"
        BaseHttpRequest.getRequest(path, request, GetWorkDetailInfoResponseObj::class.java, true)
    }

    /**
     * 扶贫工作队、驻村干部、村两委班子 列表信息
     */
    fun getTeanWorkUrl(type: String?, id: String?) {
        val request = GetTeamWorkRequestObj()
        request.type = type
        request.village = id
        val path = PartyManagerAPI.getTearWorkList
        BaseHttpRequest.getRequest(path, request, GetTeamWorkResponseObj::class.java, true)
    }

    /**
     * 获取设置组织列表
     */
    fun getSheHuiZuZhiList(communityId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = GetZuZhiRequestObj()
        request.communityId = communityId
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.getSheHuiZuZhiListUrl
        BaseHttpRequest.getRequest(path, request, GetZuZhiResponseObj::class.java, isShow)
    }


    /**
     * 获取设置组织列表
     */
    fun getSheHuiZuZhiDynamic(communityId: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = GetZuZhiRequestObj()
        request.communityId = communityId
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyManagerAPI.getSheHuiZuZhiDynamicUrl
        BaseHttpRequest.getRequest(path, request, GetZuZhiResponseObj::class.java, isShow)
    }

    /**
     * 获取社会组织详情
     */
    fun getSheHuiZuZhiDetail(id: String?) {
        val request = GetZzDetailRequestObj()
        request.id = id
        val path = PartyManagerAPI.getSheHuiZuzhiDetail + "/$id"
        BaseHttpRequest.getRequest(path, request, GetZzDetailResponseObj::class.java, true)
    }

    /**
     * 获取社会组织动态详情
     */
    fun getSheHuiZuZhiDynamicDetail(id: String?) {
        val request = GetZzDetailRequestObj()
        request.id = id
        val path = PartyManagerAPI.getSheHuiZuZhiDyanmicDetailUrl + "/$id"
        BaseHttpRequest.getRequest(path, request, GetZzDynamicDetailResponseObj::class.java, true)
    }


    /**
     *添加项目取消延期申请信息
     */
    fun projectApplyYq(request: ProjectYQRequestObj?) {
        val path = PartyManagerAPI.addProjectYQApply
        BaseHttpRequest.postRequest(path, request, ProjectYQResponseObj::class.java, true,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


}